package com.stox.client.ui.javafx.chartingy.model.node;

import javafx.scene.shape.Line;

import com.stox.client.ui.javafx.chartingy.model.plot.Data;
import com.stox.client.ui.javafx.core.util.CSS;
import com.stox.client.ui.javafx.core.util.UI;
import com.stox.shared.model.Bar;
import com.stox.shared.model.Pnf.Box;
import com.stox.shared.model.Scrip;


public class CrossPnfBox extends AbstractPnfBox {

	private final Line one = new Line();
	private final Line two = new Line();

	public CrossPnfBox(final Data<Scrip, Bar> data, final Box box) {
		super(data, box);
		UI.style(this, CSS.crossPnfBox);

		one.startXProperty().bind(boxRectangle.xProperty().add(boxRectangle.widthProperty().multiply(padding)));
		one.startYProperty().bind(boxRectangle.yProperty().add(boxRectangle.heightProperty().multiply(padding)));
		one.endXProperty().bind(boxRectangle.xProperty().add(boxRectangle.widthProperty()).subtract(boxRectangle.widthProperty().multiply(padding)));
		one.endYProperty().bind(boxRectangle.yProperty().add(boxRectangle.heightProperty()).subtract(boxRectangle.heightProperty().multiply(padding)));
		two.startXProperty().bind(one.startXProperty());
		two.startYProperty().bind(one.endYProperty());
		two.endXProperty().bind(one.endXProperty());
		two.endYProperty().bind(one.startYProperty());
		one.strokeWidthProperty().bind(boxRectangle.heightProperty().multiply(padding));
		two.strokeWidthProperty().bind(one.strokeWidthProperty());

		getChildren().addAll(boxRectangle, one, two);
	}

}
